#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,m,l,v;
struct node
{
    int d,v,a,s,e;
    int l,r;
    bool f;
}car[100001];
int su[100001];
bool flag[100001];
bool cmp(node a,node b)
{
    if(a.l==b.l)return a.r<=b.r;
    return a.l<b.l;
}
signed main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t;
    cin>>t;
    while(t--)
    {
        memset(flag,0,sizeof(flag));
        int cnt=0;
        cin>>n>>m>>l>>v;
        for(int i=1;i<=n;i++)
        {
            cin>>car[i].d>>car[i].v>>car[i].a;
            if(car[i].v<=v&&car[i].a<=0)
            {
                car[i].s=car[i].e=-1;
            }
            else if(car[i].v>v&&car[i].a>=0)
            {
                car[i].s=car[i].d;
                car[i].e=l;
            }
            else if(car[i].v>v)
            {
                car[i].s=car[i].d;
                car[i].e=car[i].d+(v*v-car[i].v*car[i].v)*1.0/(2.0*car[i].a);
            }
            else
            {
                car[i].e=l;
                car[i].s=car[i].d+(v*v-car[i].v*car[i].v)*1.0/(2.0*car[i].a);
            }
        }
        for(int j=1;j<=m;j++)cin>>su[j];
        for(int i=1;i<=n;i++)
        {
            car[i].l=lower_bound(su+1,su+m+1,car[i].s)-su;
            car[i].r=upper_bound(su+1,su+m+1,car[i].e)-su-1;
            if((car[i].r==m+1||car[i].r<car[i].l))
            {
                car[i].f=true;
                cnt++;
            }
        }
        cout<<n-cnt<<' ';
        sort(car+1,car+n+1,cmp);
        int x=0,last=-1;
        for(int i=1;i<=n;i++)
        {
            if(car[i].f)continue;
            if(car[i].l<=last)
            {
                last=min(last,car[i].r);
                continue;
            }
            else
            {
                x++;
                last=car[i].r;
            }
        }
        cout<<m-x<<endl;
    }
    fclose(stdin);
    fclose(stdout);
    return 0;
}
